﻿<?php
/**  
* SuppliesDAO.php
*   
*/

require_once(CLASS_PATH."/__autoload.php");

class SuppliesDAO extends Searchmgr
{
	protected function getQuery($keywords)
	{
		foreach($keywords as $str){
			if($this->isValid($str))
			{
				$keys[]  = " (hs.ssName LIKE '%$str%') ";  
			}
		}
	  
		if(isset($keys)) 
		{
		  $keys = array_unique($keys);      // 중복된 키워드 제거
		  $whereClause[] = join(' AND ', $keys); 
		}	
		
		$table 			= " list_Supplies AS ls, haystack_Supplies AS hs ";
		$whereClause 	=  join(' AND ', $whereClause);
		$whereClause   .=  " AND (ls.sSerial = hs.sSerial) ";
		$fields 		= 'ls.sSerial, ls.sMaker, ls.sName, ls.sColor, ls.sUnit, ls.sQuantity, ls.sType, ls.eco, ls.short, ls.sComment, hs.spSerial ';
		$order  		= 'ls.sMaker, ls.sType DESC, ls.sColor, ls.sName ';
		
		$qry = $this->db_select($table, $whereClause, $fields, $order);
		return $qry;  
	}
   
}
?>
